using System;
using System.Drawing;
using System.Globalization;
namespace CUtil
{
	/// <summary>
	/// Summary description for FormatNumbers.
	/// </summary>
	public class FormatNumbers
	{
		#region Constructors and Destructors


        public FormatNumbers()
		{
            
            //DisplayDateNCultureName(tDate, "en-US");

		}

		#endregion

		#region Methods

        public static double TruncateFloatWithDigits(double fIn, int numberOfDigits)
        {
            if (fIn == 0)
                return fIn;
            string fSplit = fIn.ToString(Conversions.CultureAmerican);

            try
            {


                string[] arrSplit = fSplit.Split(new char[] { '.' }, 100);
                if (arrSplit.GetLength(0) < 2)
                    return fIn;

                string afterComma = arrSplit[1];
                if (afterComma.Length > numberOfDigits)
                    afterComma = afterComma.Remove(numberOfDigits);
                string newNumberString = arrSplit[0] + "." + afterComma;

                double fOut = Convert.ToDouble(newNumberString, Conversions.CultureAmerican);
                return fOut;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, "Error truncating value " + fSplit + "; " + ex.Message);
                return fIn;
            }

        }
        public static string FormatStringWithTwoDigits(double fIn)
        {
            string s = fIn.ToString("N");
            return s;
        }
        public static double FormatFloatWithTwoDigits(double fIn)
        {

            string s = fIn.ToString("N");
            fIn = Convert.ToDouble(s);
            return fIn;
        }
        public static double FormatDoubleWithTwoDigits(double dIn)
        {
            
            string s = dIn.ToString("N");
            dIn = Convert.ToDouble(s);
            return dIn;
        }

		#endregion

	
	}
}
